from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


driver = webdriver.Edge()
driver.get('http://10.59.9.12:7001/')
driver.maximize_window()
# 强制等待
sleep(2)
# 点击指令
driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
# 隐式等待
driver.implicitly_wait(2)
# 输入指令
driver.find_element(By.NAME,'username').send_keys('18238680385')
sleep(2)
# 清空指令
driver.find_element(By.NAME,'username').clear()
sleep(2)
driver.find_element(By.NAME,'username').send_keys('18238680385')
sleep(1)
driver.find_element(By.NAME,'password').send_keys('123456')
# 强等输入验证码
sleep(6)
# 点击登录按钮
driver.find_element(By.XPATH,'//*[@id="theForm"]/div[5]/a').click()
sleep(5)
# 显示等待
login = By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a'
WebDriverWait(driver,20,0.5).until(EC.presence_of_element_located(login))
sleep(2)
# 获取元素的文字
user = driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').text
print(user)

sleep(5)
